package com.bysj.service;

import com.bysj.dao.GoodsReplyDao;
import com.bysj.entity.GoodsReply;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class GoodsReplyServiceImpl implements GoodsReplyService {
    @Autowired
    GoodsReplyDao goodsReplyDao;
    //添加商品评论
    @Override
    public void addGoodsReply(GoodsReply goodsReply) {
        SimpleDateFormat fmt= new SimpleDateFormat("yyyy-MM-dd");
        Date currentTime = new Date();
        String dateString = fmt.format(currentTime);
        goodsReply.setReplydate(dateString);
        goodsReplyDao.addGoodsReply(goodsReply);
    }
    //查询当前商品的所有评论
    @Override
    public List<GoodsReply> getGoodsReplyById(Integer id) {
        return goodsReplyDao.getGoodsReplyById(id);
    }

    @Override
    public void deleteReplyById(Integer id) {
        goodsReplyDao.deleteReplyById(id);
    }
}
